<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
   If Not Page.IsPostBack Then
	BindData
   End If
End Sub
Sub BindData()
Dim strConn as string = _
ConfigurationSettings.appSettings("conn")
Dim strSQL as string = "Select ItemID," & _ 
 " ItemName from tblItems"
  Dim myConn As New SQLConnection(strConn)
  Dim myDataReader as SQLDataReader
  Dim Cmd as New SQLCommand(strSQL , myConn)
  myConn.Open()
  myDataReader=Cmd.ExecuteReader( _
  system.data.CommandBehavior.CloseConnection)
  MyDataGrid.DataSource = myDataReader
  MyDataGrid.DataBind()
  myConn.close
End Sub
</script>
<html>
<head>
<title>DataGrid Control</title>
</head>
<body><div align="center">
<h2>DataGrid and DataReader</h2>
<asp:Datagrid runat="server" Id="MyDataGrid" />
</div>
</body>
</html>
